﻿using System;
using System.Collections.Generic;
using InsuranceAdjuster.Web.Models;
using InsuranceAdjuster.Services;

namespace InsuranceAdjuster.DesignServices {
    public class DesignPageConductor : IPageConductor {
        protected Dictionary<string, object> State = new Dictionary<string, object>();

        public DesignPageConductor() {
        }

        public void DisplayError(string origin, Exception e, string details) {
            return;
        }

        public void DisplayError(string origin, Exception e) {
            return;
        }

        public void GoToView(string viewToken) {
            return;
        }

        public void GoBack() {
            return;
        }

        public void PushState(string key, object value) {
            State[key] = value;
        }

        public T PopState<T>(string key) where T : class {
            //if (typeof(T) == typeof(Error))
            //{
            //    return new DesignError() as T;
            //}
            //if (typeof(T) == typeof(User))
            //{
            //    return new DesignUser() as T;
            //}            
            //if (typeof(T) == typeof(string))
            //{
            //    return "silverlight" as T;
            //}
            return PeekState<T>(key);
        }

        public T PeekState<T>(string key) where T : class {
            object value;
            State.TryGetValue(key, out value);
            return value as T;
        }

    }
}